
let confirmOrder = new Vue({
    el:"#confirmOrder",
    data:{
        order:{}
    },
    methods:{
        loadOrder:function (orderNo) {
            let form=new FormData();
            form.append("orderNo",orderNo);
            axios({
                url:"/order/getOrderDetail",
                method:"get",
                params:{
                    orderNo:orderNo
                }
            }).then(function (response) {
                console.log(response.data);
                // 订单加载成功
                if(typeof(response.data)=="object"){
                    console.log(response.data);
                    confirmOrder.order=response.data;
                }else{ //订单加载失败,跳回首页
 //                   location.href="/index.html";
                }
            });
        }
    },
    created:function () {
        let result=location.search.match(/orderNo=(\d+)/);
        console.log(result);
        // 加载订单
        if(result!=null && typeof(result)!="undefined" ){
            this.loadOrder(result[1]);
        }
    }
});

function sendPay(){
    let result=location.search.match(/orderNo=(\d+)/);
    // url中没有orderNo,跳转到首页
    if(typeof(result)=="undefined"){
        location.href="index.html";
    }else{
        axios({
            url:"/order/pay",
            method:"get",
            params:{
                orderNo:result[1] //result[1]就是订单号
            }
        }).then(function (response) {
            let pattern = /biz_content/;
            console.log(response.data);
            // 返回的内容包含biz_content表示
            if(pattern.test(response.data)){
                document.write(response.data);
            }else{
                alert(response.data);
            }
        })
    }
}